package com.xctech.yace;

import com.xctech.yace.swing.Version;
import com.xctech.yace.swing.frame.LockFrame;
import com.xctech.yace.swing.ConfigValue;
import com.xctech.yace.swing.tab.*;
import com.xctech.yace.util.CheckUtil;

import javax.swing.*;

import static java.awt.Toolkit.getDefaultToolkit;


public class YaceSwing implements ConfigValue, Version {

    public static void main(String[] args) {
        // 显示应用 GUI
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }

    /**{
     * 创建并显示GUI。出于线程安全的考虑，
     * 这个方法在事件调用线程中调用。
     */
    private static void createAndShowGUI() {
        // 确保一个漂亮的外观风格
        JFrame.setDefaultLookAndFeelDecorated(true);

        // 创建及设置窗口
        JFrame frame = new JFrame(version);
        frame.setIconImage(getDefaultToolkit().getImage("conf/icon/l1.ico"));


        //检验lincense
        if(!CheckUtil.checkLincense()){
            LockFrame lock = new LockFrame(null, "系统锁屏", true);
            lock.setVisible(true);
        }

        frame.setSize(windowsWedth,windowsHeight);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JTabbedPane tp = new JTabbedPane();

        tp.add(VersionTabSwing.genVersionSplitPanel());
        tp.setTitleAt(0,VersionTabSwing.title);

        tp.add(MoniTabSwing.genMoniSplitPanel());
        tp.setTitleAt(1,MoniTabSwing.title);

        tp.add(FromDBTabSwing.genFromDBSplitPanel());
        tp.setTitleAt(2,FromDBTabSwing.title);

        tp.add(ConversionSwing.genConvertPanel());
        tp.setTitleAt(3,ConversionSwing.title);

        tp.add(ComparatorSwing.genComparePanel(tp));
        tp.setTitleAt(4,ComparatorSwing.title);

        tp.add(YaceTabSwing.genYACESplitPanel());
        tp.setTitleAt(5,YaceTabSwing.title);

        tp.add(SelectCollectTabSwing.genSelectCollectSplitPanel());
        tp.setTitleAt(6,SelectCollectTabSwing.title);

//        tp.add(VimTableInfoSwing.genConvertPanel());
//        tp.setTitleAt(5,VimTableInfoSwing.title);

        frame.setContentPane(tp);

        frame.setLocationRelativeTo(null);//窗口在屏幕中间显示

        frame.setVisible(true);
    }

}
